package com.xiaotu.constant;

/**
 * @author zhangxiao
 * @create 2022-05-09 11:15
 */
public class RedisConstants {

    //14天-用户登录的有效期（单位毫秒）
    public static final long EXPIRE_TIME = 14 * 24 * 60 * 60 * 1000;

    //30天-昵称的修改有效期（单位秒）
    public static final long REFRESH_NICK_NAME_EXPIRE_TIME = 30 * 24 * 60 * 60;

    //设备绑定手机号的有效期（单位毫秒）延迟用户登录有效期 1天
    public static final long PHONE_BIND_ANDROID_DEVICEID_EXPIRE_TIME = EXPIRE_TIME + (1 * 24 * 60 * 60 * 1000);

    private static final String LOGIN_USER_TOKEN = "LOGIN_USER:TOKEN:";

    private static final String REFRESH_NICK_NAME = "REFRESH_NICK_NAME:PLAYER_ID:";

    private static final String PHONE_BIND_ANDROID_DEVICEID = "PHONE_BIND:ANDROID_DEVICEID:";

    /**
     * 获取登录用户 key
     *
     * @param phone
     * @return
     */
    public static String getLoginUserKey(String phone) {
        return LOGIN_USER_TOKEN + phone;
    }

    /**
     * 获取刷新昵称 key
     *
     * @param playerId
     * @return
     */
    public static String getRefreshNickNameKey(Integer playerId) {
        return REFRESH_NICK_NAME + playerId;
    }

    /**
     * 获取手机绑定安卓设备ID key
     *
     * @param phone
     * @return
     */
    public synchronized static String getPhoneBindAndroidDeviceIdKey(String phone) {
        return PHONE_BIND_ANDROID_DEVICEID + phone;
    }

}
